<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY nbsp "&#x00A0;">
]>
<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:msxml="urn:schemas-microsoft-com:xslt"
  xmlns:site.library="urn:site.library"
  xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"   xmlns:examine="urn:examine"
  exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets  examine site.library">

  <xsl:output method="xml" omit-xml-declaration="yes" indent="no"/>
  <xsl:param name="currentPage"/>
  <xsl:variable name="isEditMode" select="site.library:IsCanvas()"/>
  <xsl:variable name="macroPage" select="umbraco.library:GetXmlNodeById(string(/macro/macroPage))"/>
  

  <xsl:template match="/">
    <div class="widget content-widget">
    <xsl:variable name="source" select="$macroPage"/>
    <xsl:variable name="link"><xsl:choose>
        <xsl:when test="string-length($source/navigateUrl)>0"><xsl:value-of select="$source/navigateUrl" disable-output-escaping="yes"/></xsl:when>
        <xsl:when test="$source/navigateToNode/nodes/*[1]/@type='media'"><xsl:value-of select="umbraco.library:GetMedia($source/navigateToNode/nodes/*[1]/@id, false)/umbracoFile" disable-output-escaping="yes" /></xsl:when>
        <xsl:when test="$source/navigateToNode/nodes/*[1]/@type='content'"><xsl:value-of select="umbraco.library:NiceUrl($source/navigateToNode/nodes/*[1]/@id)" disable-output-escaping="yes" /></xsl:when>
    </xsl:choose></xsl:variable>
    <xsl:if test="number($source/image)>0">
        <img alt="{name($source)}" src="{umbraco.library:GetMedia($source/image, false)/umbracoFile}" />
      </xsl:if>      
      <xsl:if test="string-length($source/title)>0">
        <h2 class="title">
          <xsl:value-of disable-output-escaping="yes" select="$source/title"/>
        </h2>
    </xsl:if>
    <xsl:if test="string-length($source/content)>0">          
      <xsl:value-of disable-output-escaping="yes" select="$source/content"/>
    </xsl:if>
    <xsl:if test="string-length($link)>0">
        <a href="{$link}" class="link-button">
          <xsl:if test="string-length($source/target) >0"><xsl:attribute name="target"><xsl:value-of select="$source/target"/></xsl:attribute></xsl:if>
          <xsl:choose>
            <xsl:when test="$source/linkTitle != ''"><xsl:value-of disable-output-escaping="yes" select="$source/linkTitle"/></xsl:when>
            <xsl:otherwise><xsl:call-template name="comment"><xsl:with-param name="text" select="'no button text!'"/></xsl:call-template></xsl:otherwise>
          </xsl:choose>
          <ins><xsl:call-template name="comment"/></ins>
        </a>      
    </xsl:if>
      <xsl:call-template name="comment">
        <xsl:with-param name="text" select="$macroPage/@nodeName"/>
      </xsl:call-template>
    </div>
  </xsl:template>

  
  
  <xsl:template name ="comment">
    <xsl:param name="text" select="''"/>
    <xsl:text disable-output-escaping="yes">&lt;!--  </xsl:text> <xsl:value-of disable-output-escaping="yes" select="$text"/><xsl:text disable-output-escaping="yes"> --&gt;</xsl:text>
  </xsl:template>
</xsl:stylesheet>